 sbtl 'global pages - 64k'
 org globals 
*
entry jmp mlient1 ;mli call entry point
*
************ see rev note #36 *************************
*
*jspare jmp sys.rts ;jump vector to cold start/selector program, etc. 
jspare jmp jspare ; will be changed to point to dispatcher
*                               caller by the loader.
*******************************************************
datetime dfb $60 ; changed to $4c (jmp) if clock present.
 dw tclk.in ; clock routine entry address.
syserr jmp syserr1 ;error reporting hook.
sysdeath jmp sysdeath1 ;system failure hook.
serr dfb $00 ;error code, 0=no error.
 skp 1
*
* device driver vectors. 
*
devadr01 dw gnodev ;slot zero reserved
 dw gnodev ;slot 1, drive 1
 dw gnodev ;slot 2, drive 1
 dw gnodev ;slot 3, drive 1
 dw gnodev ;slot 4, drive 1
 dw gnodev ;slot 5, drive 1
 dw gnodev ;slot 6, drive 1
 dw gnodev ;slot 7, drive 1
 dw gnodev ;slot zero reserved
 dw gnodev ;slot 1, drive 2 
 dw gnodev ;slot 2, drive 2 
 dw gnodev ;slot 3, drive 2 
 dw gnodev ;slot 4, drive 2 
 dw gnodev ;slot 5, drive 2 
 dw gnodev ;slot 6, drive 2 
 dw gnodev ;slot 7, drive 2 
 skp 1
*
* configured device list by device number
* access order is last in list first.
*
devnum dfb $00 ;most recent accessed device. 
devcnt dfb $ff ;number of on-line devices (minus 1). 
devlst dfb $0,0,0,0 ;up to 14 units may be active. 
 dfb 0,0,0,0,0 
 dfb 0,0,0,0,0 
 skp 1
 ifeq os-prodos
 asc "(C)APPLE'83" ; AppleTALK writes over this area! DO NOT MOVE!
 fin
mlient1 php
 sei
 jmp mlicont
aftirq sta ramin
 jmp fix45 ;restore $45 after interrupt in lang card
*
****** see rev note #en3 ******
*
* note: this code was moved down here so a branch could reach gorpm.
*
 ifeq os-ednet
rpm.entry equ *
 php  ; needs 2 since bridge eats one of 'em.
 php  ; done since we return via rti.
 pha  ; save outgoing character on stack.
 bit $ff58 ; set v flag for rpm.
 bvs rpmcont ; branch always...
gorpm jmp rpm.stub ; call rpm.
 fin
*******************************
*
 ds $bf56-*,0 ; got to align this stuff!
*
old45 dfb 0
afbank dfb 0
 skp 1
*
* memory map of the lower 48k.  each bit represents one page
* (256 bytes) of memory.  protected areas are marked with a
* 1, unprotected with a 0.  prodos dis-allows reading or
* buffer allocation in protected areas.
*
memtabl dfb $c0,$00,$00,$00,$00,$00,$00,$00
 dfb $00,$00,$00,$00,$00,$00,$00,$00
 dfb $00,$00,$00,$00,$00,$00,$00,$01 
 page 
*
* the addresses contained in this table are buffer addresses
* for currently open files.  these are informational only,
* and should not be changed by the user except through the 
* mli call setbuf.
*
gl.buff dw $0000 ;file number 1 
 dw $0000 ;file number 2 
 dw $0000 ;file number 3 
 dw $0000 ;file number 4 
 dw $0000 ;file number 5 
 dw $0000 ;file number 6 
 dw $0000 ;file number 7 
 dw $0000 ;file number 8 
 skp 1
*
* interrupt vectors are stored here.  again, this area is
* informational only, and should be changed only by calls
* to the mli to allocate_interrupt.  values of the a, x, y,
* stack, and status registers at the time of the most recent
* interrupt are also stored here.  in addition, the address
* interrupted is also preserved.  these may be used for
* performance studies and debugging, but should not be changed
* by the user.
*
intrupt1 dw $0000 ;interupt routine 1 
intrupt2 dw $0000 ;interupt routine 2 
intrupt3 dw $0000 ;interupt routine 3 
intrupt4 dw $0000 ;interupt routine 4 
intareg dfb $00 ;a-register 
intxreg dfb $00 ;x-register 
intyreg dfb $00 ;y-register 
intsreg dfb $00 ;stack register 
intpreg dfb $00 ;status register 
intbankid dfb $01 ;rom, ram1, or ram2 ($d000 in lc) 
intaddr dw $0000 ;program counter return addr. 
 skp 1
*
* the user may change the following options prior
* to calls to the mli.
*
datelo dw $0000 ;bits 15-9=yr, 8-5=mo, 4-0=day 
timelo dw $0000 ;bits 12-8=hr, 5-0=min; low-hi format. 
level dfb $00 ;file level: used in open, flush, close. 
bubit dfb $00 ;backup bit disable, setfileinfo only. 
spare1 dfb $00 ; Used to save A reg
newpfxptr dfb $00 ; used as AppleTalk alternate prefix ptr
 page 
*
* the following are informational only.  machid identifies
* the system attributes:
* (bit 3 off) bits 7,6-  00=ii  01=ii+   10=iie   11=/// emulation
* (bit 3 on)  bits 7,6-  00=na  01=na    10=//c   11=na
*             bits 5,4-  00=na  01=48k   10=64k   11=128k
*             bit  3    modifier for machid bits 7,6. 
*             bit  2    reserved for future definition. 
*             bit  1=1-  80 column card
*             bit  0=1-  recognizable clock card
*
* sltbyt indicates which slots are determined to have roms.
* pfixptr indicates an active prefix if it is non-zero.
* mliactv indicates an mli call in progress if it is non-zero.
* cmdadr is the address of the last mli call's parameter list.
* savx and savy are the values of x and y when the mli 
*  was last called.
*
machid dfb $00 ;machine identification. 
sltbyt dfb $00 ;'1' bits indicate rom in slot(bit#) 
pfixptr dfb $00 ;if = 0, no prefix active.. 
mliactv dfb $00 ;if <> 0, mli call in progress
cmdadr dw $0000 ;return address of last call to mli. 
savex dfb $00 ;x-reg on entry to mli
savey dfb $00 ;y-reg on entry to mli
 skp 1
*
* the following space is reserved for language card bank
* switching routines.  all routines and addresses are
* subject to change at any time without notice and will, 
* in fact, vary with system configuration.
* the routines presented here are for 64k systems only. 
*
 skp 1
exit eor $e000 ;test for rom enable. 
 beq exit1 ;branch if ram enabled.
 sta romin ;else enable rom and return.
 bne exit2 ;branch always 
 skp 1 
exit1 lda bnkbyt2 ;for alternate ram (mod by mlient1) 
 eor $d000 ; enable.
 beq exit2 ;branch if not alternate ram.
 lda altram ;else enable alt $d000
exit2 pla ;restore return code.
 rti ;re-enable interupts and return 
 skp 1 
mlicont sec 
 ror mliactv ;indicate to interupt routines mli active.
*
***** see rev note #en3 *******
*
 ifeq os-ednet
 clv  ; overflow flag must be cleared for standard mli call.
 fin
*******************************
rpmcont lda $e000 ;preserve language card / rom 
 sta bnkbyt1 ; orientation for proper 
 lda $d000 ; restoration when mli exits...
 sta bnkbyt2 
 lda ramin ;now force ram card on
 lda ramin ; with ram write allowed.
*
*********** see rev note #en3 ************
*
 ifeq os-ednet
 bvs gorpm ; if v set go do rpm.
 fin
******************************************
 jmp entrymli
 page 
*
* interupt exit/entry routines
*
 skp 1
irqxit lda intbankid ;determine state of ram card 
irqxit0 beq irqxit2 ; if any.  branch if enabled.
 bmi irqxit1 ;branch if alternate $d000 enabled.
 lsr a ;determine if no ram card present.
 bcc romxit ;branch if rom only system.
 lda romin1 ;else enable rom first.
 bcs romxit ;branch always taken...
irqxit1 lda altram ;enable alternate $d000.
irqxit2 lda #1 ;preset bankid for rom.
 sta intbankid ;(reset if ram card interupt)
romxit lda intareg ;restore accumulator...
 rti ; and exit!
 skp 1
irqent bit ramin ;this entry only used when rom
 bit ramin ; was enabled at time of interupt.
 jmp irqrecev ; a-reg is stored at $45 in zpage.
bnkbyt1 dfb $00
bnkbyt2 dfb $00
 skp 1
*
*************** see rev note #36 **********************
*
*sys.rts bit ramin ;make certain language card is switched in
* jmp sys.end ;or anywhere else we need to go
*
*******************************************************
*
*
*
 ds $bffc-*,0 ; pad
ibakver dfb $00 ; reserved
iversion dfb $00 ;version # of currently running interpreter
 skp 2
kbakver dfb $00 ;undefined: reserved for future use
kversion dfb $07 ; Represents release 1.7
;
